package com.jkoss.biz.imp.kc;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jkoss.biz.kc.qtionbiz;
import com.jkoss.dao.kc.QuestionMapper;
import com.jkoss.pojo.kc.Question;
import com.jkoss.tool.Page;

@Component
public class qtionbizimp implements qtionbiz{

	@Autowired
	private QuestionMapper qdao;
	@Override
	public List<Question> showqusetion(Page<Question> page) {
		// TODO Auto-generated method stub
		return qdao.findByAll(page);
	}
	@Override
	public int addcst(Question qs) {
		// TODO Auto-generated method stub
		return qdao.insert(qs);
	}
	@Override
	public int delqt(String qid) {
		
		int id = Integer.parseInt(qid);
		return qdao.deleteByPrimaryKey(id);
	}
	@Override
	public Question findCstByOne(String qid) {
		
		Question question =qdao.findByOne(qid);
		return question;
	}
	@Override
	public int upcst(Question qs) {
		// TODO Auto-generated method stub
		return qdao.updateByPrimaryKey(qs);
	}
	@Override
	public List<Question> findCstBySome(Page<Question> page,Integer sbid) {

		
		if(sbid==null||sbid==0){
			return qdao.findByAll(page);
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("sbid", sbid);
		page.setParams(params);
		return qdao.findBySome(page);
	}

}
